//
//  AddAdressViewController.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/28.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "AddAdressViewController.h"
#import "AddAndEditAdressViewModel.h"
#import "AdressChangeViewController.h"

@interface AddAdressViewController ()<AdressEditDelegate>
@property (nonatomic,strong)AddAndEditAdressViewModel * adressEditViewModel;
@end

@implementation AddAdressViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.adressEditViewModel = [[AddAndEditAdressViewModel alloc] initWithViewToViewModel:self.tableView theSuperView:self.view theAdresModel:self.adressInfor];
    self.adressEditViewModel.delegate = self;
    if (self.adressInfor) {
        self.title = @"编辑收货地址";
        [self addNavigationItemWithTitles:@[@"删除"] isLeft:NO target:self action:@selector(deleteAdree) tags:@[@44] theButTitColor:[UIColor colorWithHexString:@"#666666"] titFont:SYSTEMFONT(14)];
    }else{
        self.title = @"新建收货地址";
    }
}

-(void)deleteAdree{//
    [self.adressEditViewModel deleteAdress];
}
#pragma mark -- AdressEditDelegate
-(void)pushAdressSelect{
    AdressChangeViewController * adressVC = [AdressChangeViewController new];
    [self.navigationController pushViewController:adressVC animated:YES];
}

-(void)adressEditSuccess:(NSString *)tos_Str theAddEdit:(AddOrEditType)editType{
    [GLGWProgressHUD showNotice:tos_Str view:nil];
    if (self.Block_CaoZuoAccount) {
        self.Block_CaoZuoAccount(editType);
    }
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)delegateSuccess:(NSString *)tos_Str{
    [GLGWProgressHUD showNotice:tos_Str view:nil];
    if (self.Block_CaoZuoAccount) {
        self.Block_CaoZuoAccount(5);
    }
    [self.navigationController popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
